package com.ecreditpal.audio.rpc.client;


import com.ecreditpal.audio.rpc.client.model.Speech;
import com.ecreditpal.audio.rpc.client.model.SpeechServiceGrpc;
import com.ecreditpal.audio.rpc.client.starter.GrpcClient;
import com.google.protobuf.ByteString;
import io.grpc.Channel;

import org.springframework.stereotype.Service;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
 */
@Service
public class RpcSpeechClientService {

    //消费自身的服务
    @GrpcClient("SPEECH-SEG-SERVICE")
    private Channel serverChannel;

    public List<Double> sendMessage(byte[] data) {
        SpeechServiceGrpc.SpeechServiceBlockingStub stub = SpeechServiceGrpc.newBlockingStub(serverChannel);
        Speech.SpeechResponse response = stub.speechSeg(Speech.SpeechRequest.newBuilder().setSpeech(ByteString.copyFrom(data)).build());
        return response.getSegMillsList();
    }
}
